import { StatusBar } from "expo-status-bar";
import { Platform, StyleSheet, View, Text } from "react-native";
import "../../global.css";
import { useSelector } from "react-redux";
import { RootState } from "../../redux/store"; // 导入类型

export default function SubScreen() {
  const name = useSelector((state: RootState) => state.test.name);
  const age = useSelector((state: RootState) => state.test.age);

  return (
    <View style={styles.container}>
      <Text className="text-3xl">子页面</Text>
      <Text>
        从redux中拿到的test切片的数据：
        <Text>
          name:{name},age:{age}
        </Text>
      </Text>
      <StatusBar style={Platform.OS === "ios" ? "light" : "auto"} />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: "center",
    justifyContent: "center",
  },
  title: {
    fontSize: 20,
    fontWeight: "bold",
    color: "red",
  },
  separator: {
    marginVertical: 30,
    height: 1,
    width: "80%",
  },
});
